package com.dragon.repository.domain.vo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.dragon.common.model.Update;
import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.OtherFile;
import com.dragon.repository.entity.Produce;
import com.dragon.repository.entity.WorkflowJson;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import jdk.nashorn.internal.runtime.linker.LinkerCallSite;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class ProduceVO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "合同id")
    private Integer contractId;

    @ApiModelProperty(value = "用户id")
    private Integer adminId;

    @ApiModelProperty(value = "部门id")
    private Integer departmentId;

    @ApiModelProperty(value = "生产单号")
    private String number;

    @ApiModelProperty(value = "生产的名称")
    private String name;

    @ApiModelProperty(value = "生产数量")
    private Long quantity;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date updateTime;

    @ApiModelProperty(value = "生产截至时间")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date endTime;

    @ApiModelProperty(value = "交货时间")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date deliveryTime;


    @ApiModelProperty(value = "生产状态：0.待生产1.生产中2.生产完成")
    private Integer type;

    @ApiModelProperty(value = "审核状态：0待审核 1审核通过 2审核不通过 3作废 4删除")
    private Integer status;

    @ApiModelProperty(value = "备注")
    private String remark;

    @ApiModelProperty(value = "0生产单 1生产单(重做) 2生产单维修")
    private Integer source;

    @ApiModelProperty(value = "负责人id")
    private Integer responsibleId;

//    @ApiModelProperty(value = "工作流json")
//    private List<WorkflowJson> workflowJsonList;

    @ApiModelProperty(value = "附件")
    private List<OtherFile> otherFileList;

    @ApiModelProperty(value = "合同地址")
    private String contractAddress;

    @ApiModelProperty(value = "客户id")
    private Integer customerId;

    @ApiModelProperty(value = "免审操作：0，不免审，1免审")
    private Integer exempt;

    @ApiModelProperty(value = "客户名称")
    private String customerName;

    @ApiModelProperty(value = "收货状态")
    private Integer deliverStatus;

    @ApiModelProperty(value = "排产状态 0未排产 1部分排产 2排产完成")
    public Integer schedulingStatus;

    @ApiModelProperty(value = "退货单id")
    private Integer rejectedId;

    @ApiModelProperty(value = "完成状态 0未完成，1部分完成 2全部完成")
    private Integer finishedStatus;

    @ApiModelProperty(value = "生产产品列表")
    @NotNull(message = "产品不能为空")
    private List<ProduceProductsVO> produceProductsVOS;

    @NotNull(groups = Update.class,message = "主键不能为空")
    public static Produce convert(ProduceVO vo) {
        Produce entity = new Produce();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<Produce> convertList(List<ProduceVO> list) {
        List<Produce> resultList = new ArrayList<>();
        for (ProduceVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
